#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import pow as pingfang

print pingfang(3,2)

# number = raw_input("Please input number:")
#
# if int(number) == 10:
#     print "number you are smart"
# elif int(number) > 10:
#     print "number more than 10"
# else:
#     print "number less than 10"

'''三元运算'''
sex = 'man'
name = "Mark" if sex == 'man' else "Yuki"
'''总结一下：A = Y if X else Z'''
# 结合前面的例子，可以看出：
# 如果 X 为真，那么就执行 A=Y
# 如果 X 为假，就执行 A=Z
print name # 因为sex == ‘man’为真,所以name就为Mark,如果sex不是‘man’的话,name就会变成‘Yuki’

'''for 循环'''
for i in range(0,10,1):
    print i
    i+1

'''求出100以内能被3整除的正整数'''
aliquot = []

for n in range(1,100):
    if n%3 == 0:
        aliquot.append(n)

print aliquot
'''最弱智的方法求出100以内能被3整除的正整数'''
print range(3,100,3) # 超弱智!!!

a_dict = {"name":"qiwsir", "lang":"python", "email":"qiwsir@gmail.com", "website":"www.itdiffer.com"}
for k in a_dict.keys():
    print k, a_dict[k]

'''zip()的用法'''
str1 = "python"
str2 = "markyu"
print zip(str1, str2)

num1 = [1, 2, 3]
num2 = [4, 5, 6, 7]
print zip(num1, num2) # 如果序列长度不同，那么就以"the length of the shortest argument sequence"为准

'''enumerate()用法'''
week = ['Sun', 'Mon', 'Tues', 'Wen', 'Thurs', 'Fri', 'Staur']
for (i, day) in enumerate(week):
    print day + ' is ' + str(i)

seasons = ['Spring', 'Summer', 'Fall', 'Winter']
print list(enumerate(seasons, start= 1))

'''趣味小练习'''
raw = "Do you love Mark_Lin ? Mark_Lin is a good teacher."
raw_lst = raw.split(" ")
for i, string in enumerate(raw_lst):
    if string == "Mark_Lin":
        raw_lst[i] = "Python"

print raw_lst

'''list的解析'''
squares = [x**2 for x in range(1, 10)]
print squares

'''while do 用法'''
# i = 1
# while i < 4:
#     password = raw_input("Please input your password:")
#
#     if password == '881206':
#         print 'Password Right!!!'
#     else:
#         print 'Password is wrong!!!'
#         print 'You have {count} chance to input'.format(count = str(3-i))
#
#     i +=1
#
'''检测用户输入的内容'''
# num_input = raw_input("Please input a number of your love in 1 to 100")
# if not num_input.isdigit():
#     print "Please input interger!!!"
# elif int(num_input) < 0 and int(num_input) > 100:
#     print "The number should be in 1 to 100."
# else:
#     pass

'''break和continue用法'''
a = 8
while a:
    if a%2 == 0:
        break
    else:
        print "%d is odd number"%a
        a = 0
print "%d is even number"%a

b = 9
while b:
    if b%2 == 0:
        b -=1
        continue # 如果是偶数，就返回循环的开始
    else:
        print "%d is odd number"%b # 如果是奇数，就打印出来
        b -=1

'''while else用法'''
count = 0
while count < 5:
    print count, "is less than 5"
    count = count + 1
else:
    print count, "is not less than 5"